<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
     
      <el-form-item label="接龙内容验证：">
        <el-switch v-model="form.jielongMsgCheckSwitch" 
          active-text="已开启文本验证" 
          inactive-text="未开启文本验证" />
      </el-form-item>
      
      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button>
        <el-button @click="onCancel">Cancel</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getJielongMsgCheckSwitch,changeJielongMsgCheckSwitch } from '@/api/system'
export default {
  data() {
    return {
      form: {
        jielongMsgCheckSwitch: null,
        jielongMsgCheckSwitchTitle: null
      }
    }
  },
  created() {
    this.fetchJielongMsgChcekData()
  },
  methods: {
    fetchJielongMsgChcekData() {
      getJielongMsgCheckSwitch().then(response => {
        var s = response.data.switch
        this.form.jielongMsgCheckSwitch=s
        this.form.jielongMsgCheckSwitchTitle=s ? "开启":"未开启"
      })
    },

    onSubmit() {
      this.$message('submit!')
      var param = {
        switch: this.form.jielongMsgCheckSwitch 
      }
      changeJielongMsgCheckSwitch(param).then(response => {
        if (response && response.resultCode == '0') {
          this.$message({
            message: '设置成功!',
            type: 'success'
          })
        } else {
          this.$message({
            message: '请求失败!',
            type: 'error'
          })
        }
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

